<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

</head>

<body>
	<p style="font-size:25px">
		当前页数:[${param.pageNo }/${param.pageCount}]&nbsp;&nbsp;&nbsp;&nbsp;
		<c:if test="${param.pageNo>1 }">
			<a href="javascript:search(1,${param.pageSize })">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;
		  				<a href="javascript:search(${param.pageNo-1 },${param.pageSize})">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
		  			</c:if>
		<c:if test="${param.pageNo<param.pageCount }">
			<a href="javascript:search(${param.pageNo+1 },${param.pageSize})">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:search(${param.pageCount },${param.pageSize })">末页</a>&nbsp;&nbsp;&nbsp;&nbsp;
					</c:if>
		总${param.totalCount }条&nbsp;&nbsp;&nbsp;&nbsp; 每页显示 <select name="pageSize">
			<option value="5" ${param.pageSize==5?"selected":"" }>5</option>
			<option value="6" ${param.pageSize==6?"selected":"" }>6</option>
			<option value="10" ${param.pageSize==10?"selected":"" }>10</option>
		</select>条&nbsp;&nbsp;&nbsp;&nbsp; 跳转到第<input type="text" id="pageIndex"
			name="pageIndex" value="" size="1">页&nbsp;&nbsp;
		<button type="button" onclick="go()">GO</button>

	</p>
	<script type="text/javascript">
		function go(){
			//获取输入的页码
			var pageIndex = parseInt(document.getElementById("pageIndex").value);
			var maxPage = parseInt(document.getElementById("pageCount").value);
			//校验页码输入是否正确
			//格式为数字
			var reg = /^[1-9]{1}[0-9]{0,}$/;
			if(reg.test(pageIndex) && pageIndex<=maxPage){
				//如果验证正确，提交请求
				search(pageIndex);
			}else{
				alert("请输入正确的页码！页码范围为1-"+maxPage+"。");
				document.getElementById("pageIndex").value="";
				document.getElementById("pageIndex").focus();
				return;
			}
		}
		
		function search(pageNo,pageSize){
			if(pageSize){
				document.getElementById("pageSize").value = pageSize;
			}
			document.getElementById("pageNo").value = pageNo;
			document.forms[0].submit();
		}
	
	</script>
</body>
</html>
